<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@page session="true"%>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/pages/util/configurationPage.jsp"/>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/DataTables-1.10.4/media/css/jquery.dataTables.css">
    <script type="text/javascript" language="javascript" src="<%=request.getContextPath()%>/static/DataTables-1.10.4/media/js/jquery.js"></script>
    <script type="text/javascript" language="javascript" src="<%=request.getContextPath()%>/static/DataTables-1.10.4/media/js/jquery.dataTables.js"></script>

    <script type="text/javascript" language="javascript">
        $(document).ready(function() {
            var adjusted1 = false;
            $('#listTable').dataTable( {
                language: {"url": "<%=request.getContextPath()%>/static/DataTables-1.10.4/Polish.json"},
                processing: true,
                ajax: "getSegmentsList",
                columns: [
                    {"title":"Nazwa", "data": "name" },
                    {"title":"Akcje", "data": "id" }
                ],
                columnDefs: [
                {
                    "render": function(data, type, row) {
                    var url = "${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}/orbeon/fr/";
                    var stringQuery = "?username=${pageContext.session.getAttribute('com.skb.model.User')}&group=${pageContext.session.getAttribute('com.skb.model.UserDepartment')}";
                    return "<div class='btn-group text-left'>"+
                                "<button type='button' class='btn btn btn-primary dropdown-toggle' data-toggle='dropdown'>"+
                                "<i class='glyphicon glyphicon-cog'></i> Akcje <span class='caret'></span>"+
                                "</button><ul class='dropdown-menu' role='menu'>"+
                                "<li><a href='<c:url value='/admin/segment/editSegment'/>?id=" + row.id + "'><i class='glyphicon glyphicon-pencil'></i> Edytuj </a></li>"+
                                "<li><a href='<c:url value='/admin/segment/editInterestRate'/>?id=" + row.interestRateId + "'><i class='glyphicon glyphicon-usd'></i> Edytuj oprocentowanie </a></li>"+
                                "<li><a href='<c:url value='/admin/segment/editCommissionRate'/>?id=" + row.commissionRateId + "'><i class='glyphicon glyphicon-euro'></i> Edytuj prowizje </a></li>"+
                            "</ul></div>";
                    },
                    "orderable": false,
                    "width": "30%",
                    "className": "do text-center no-sorting",
                    "targets": -1
                },
                {
                    "targets": "_all",
                    "createdCell": function(td, cellData, rowData, row, col) {
                    $(td).attr('role', 'gridcell');
                    },
                }
                ],
            } );
        } );
    </script>
</head>
<body class="bg-body">
    <jsp:include page="./../../util/navbar/navbarMain.jsp"/>
    <br>
    <div class="container">
        <div class="row">
            <div class="panel panel-info">
                <c:if test="${not empty error}">
                    <div class="alert alert-danger text-center" role="alert"><strong>${error}</strong></div>
                </c:if>
                <c:if test="${not empty msg}">
                    <div class="alert alert-success text-center" role="alert"><strong>${msg}</strong></div>
                </c:if>
                <div class="panel-heading text-center"><h2><b>Rodzaje kont</b></h2></div>
                <br>
                <div class="container">
                    <table id="listTable" class="display table-bordered" cellspacing="0" width="100%"></table>
                </div>
                <br>
                <div class="col-lg-12 text-center">
                    <a class="btn btn-success" href="<c:url value="/admin/segment/addSegment"/>" ><i class="glyphicon glyphicon-plus"></i> Dodaj nowy rodzaj</a>
                </div>
                <br>
            </div>
        </div>
    </div>
    <jsp:include page="./../../util/footer.jsp"/>
</body>
</html>